home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
vbdatabs
/
winmain.h
< prev
next >
Wrap
C/C++ Source or Header
|
1999-03-17
|
15KB
|
446 lines
// ------------------------------- //
// -------- Start of File -------- //
// ------------------------------- //
// ----------------------------------------------------------- //
// C++ Header File Name: winmain.h
// C++ Compiler Used: MSVC40, HPUX CPP 10.24
// Produced By: Doug Gaer
// File Creation Date: 12/16/1997
// Date Last Modified: 03/18/1999
// Copyright (c) 1997 Douglas M. Gaer
// ----------------------------------------------------------- //
// ---------- Include File Description and Details ---------- //
// ----------------------------------------------------------- //
/*
The VBD C++ classes are copyright (c) 1997, by Douglas M. Gaer.
All those who put this code or its derivatives in a commercial
product MUST mention this copyright in their documentation for
users of the products in which this code or its derivative
classes are used. Otherwise, you have the freedom to redistribute
verbatim copies of this source code, adapt it to your specific
needs, or improve the code and release your improvements to the
public provided that the modified files carry prominent notices
stating that you changed the files and the date of any change.
THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND.
THE ENTIRE RISK OF THE QUALITY AND PERFORMANCE OF THIS SOFTWARE
IS WITH YOU. SHOULD ANY ELEMENT OF THIS SOFTWARE PROVE DEFECTIVE,
YOU WILL ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR
CORRECTION.
This is a test program used to test the (P)ersistent base class
in a practical database application using the wxWindow GUI library
version 1.68
*/
// ----------------------------------------------------------- //
#ifndef __WINMAIN_HPP__
#define __WINMAIN_HPP__
#include "grocery.h"
#include "config.h"
#include "timer.h"
#include "version.h"
#include "groc_sh.h"
#include "pscript.h"
#ifdef __GNUG__
#pragma implementation
#pragma interface
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx_prec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx.h"
#endif
// Define this macro to use the wxWindows printing features under
// Microsoft Windows. A separate PostScript driver is provided for
// UNIX system. Define this macro for UNIX compiles to enable MSW
// style printing in motif using wxWindow 1.68B.
// #ifndef __USE_MSW_PRINTING__
// #define __USE_MSW_PRINTING__
// #endif
#ifdef __USE_MSW_PRINTING__
// Setup wxWindows printing for MSW
#if !USE_PRINTING_ARCHITECTURE
#error You must set USE_PRINTING_ARCHITECTURE to 1 in wx_setup.h to compile
#endif
#include "wx_mf.h"
#include "wx_print.h"
#endif // __USE_MSW_PRINTING__
// Define new frame types for wxWindow frames and sub-frames
class MyFrame; // Main window frame
class MyTextWindow; // Text windos frames
class MyText; // Class used to encapsulate wxText objects
// Define configurable parameters
int CacheSize = 15; // Memory cache size for the index file
int AdminRights = 0; // Define user privileges
// Define file access modes used in the application
VBDFile::AccessMode RWMode = VBDFile::READWRITE;
VBDFile::AccessMode ROMode = VBDFile::READONLY;
// Function prototypes for wxWindows controls
void AddBtnProc(wxButton& but, wxCommandEvent& event);
void ClearAddPanel();
void ChBtnProc(wxButton& but, wxCommandEvent& event);
void ClearChangePanel();
void DsBtnProc(wxButton& but, wxCommandEvent& event);
void ClearDisplayPanel();
void text_proc(wxText &but, wxCommandEvent &event);
#ifdef __USE_MSW_PRINTING__
void page_btn_proc(wxButton& but, wxCommandEvent& event);
#endif // __USE_MSW_PRINTING__
// File menu functions
void ExportToASCII(MyTextWindow &textWin);
void ImportFromASCII(MyTextWindow &textWin);
void BackUp(MyTextWindow &textWin);
void Merge(MyTextWindow &textWin);
void CreateTemplate(MyTextWindow &textWin);
void CompareIndexFile(MyTextWindow &textWin);
void RebuildIndexFile(MyTextWindow &textWin);
// Database menu functions
void Add(MyTextWindow &textWin);
void Change(MyTextWindow &textWin);
void Remove(MyTextWindow &textWin, char *keyNM = 0);
void DisplayDB(MyTextWindow &textWin);
void SetPurchasing(MyTextWindow &textWin, char purchasing);
// Find menu functions
void FindBy(MyTextWindow &textWin, const char *MemberName, GrocDBItem item);
// Print menu functions
void ASCIIPrintAll(MyTextWindow &textWin);
void PostScriptPrint(MyTextWindow & textWin);
// View menu functions
void Clear(MyTextWindow &textWin);
void ViewTotals(MyTextWindow &textWin);
// Function prototypes for non-menu functions
void DisplayObject(Grocery &grocery);
int LoadIndexKeys(int load_all = 1);
void LoadGKeys(EntryKey &e);
void ReOrderDisplayList();
void PrintItemBar(ofstream &stream);
void PrintLineByLine(Grocery &grocery, ofstream &stream);
void PostScriptPrintTotals(MyTextWindow &textWin, ofstream &stream,
PostScriptDrv &psdrv);
int PrintPSItemBar(ofstream &stream, PostScriptDrv &psdrv,
int x_offset, int char_offset, int max_len);
// Search functions
void GrocDBSearch(Grocery &grocery, GrocDBItem item, UString &str,
MyTextWindow &textWin, const char *wildcard = 0);
// Version number for this windows program
char *VerNumber();
// Control key macro used for wxWindows key events
#define CONTROL(c) ((c) & 037)
// Identification for the all wxWindows main menu functions
enum MainMenu {
// File menu constants
FILE_QUIT = 1,
FILE_VBDSTATS,
FILE_EXPORT,
FILE_IMPORT,
FILE_BACKUP,
FILE_MERGE,
FILE_TEMPLATE,
FILE_COMPARE_INDEX,
FILE_REBUILD_INDEX,
// Edit menu constants
EDIT_CUT,
EDIT_COPY,
EDIT_PASTE,
// Database menu constants
DB_DISPLAY_PURCHASING,
DB_DISPLAY_ALL,
DB_ADD,
DB_CHANGE,
DB_REMOVE,
DB_RESET_PURCHASING,
DB_SET_ALL_PURCHASING,
// Find menu constants
FIND_BYNAME,
FIND_BYBRAND,
FIND_BYSTORE,
// Print menu constants
WXPRINT_PRINT_PURCHASING,
WXPRINT_PRINT_ALL,
WXPRINT_PRINTER_SETUP,
WXPRINT_PREVIEW_PURCHASING,
WXPRINT_PREVIEW_ALL,
WXPRINT_PAGE_SETUP,
PRINT_POSTSCRIPT_PURCHASING,
PRINT_POSTSCRIPT_ALL,
PRINT_ASCII_PURCHASING,
PRINT_ASCII_ALL,
// View menu constants
VIEW_CLEAR,
VIEW_TOTAL_PURCHASING,
VIEW_TOTAL_ALL,
// Help menu constants
HELP_ABOUT,
HELP_USERLEVEL
};
// Define control button tags for wxWindow panel buttons
#define ADD_BUTTON_ADD 1
#define ADD_BUTTON_CANCEL 2
#define ADD_BUTTON_CLOSE 3
#define ADD_BUTTON_REVERT 4
#define CHANGE_BUTTON_CM 11
#define CHANGE_BUTTON_CANCEL 12
#define CHANGE_BUTTON_CLOSE 13
#define CHANGE_BUTTON_REVERT 14
#define CHANGE_BUTTON_SH 15
#define DISPLAY_BUTTON_NX 21
#define DISPLAY_BUTTON_PREV 22
#define DISPLAY_BUTTON_CHANGE 23
#define DISPLAY_BUTTON_CLOSE 24
#define DISPLAY_BUTTON_REMOVE 25
#ifdef __USE_MSW_PRINTING__
#define PAGE_DIALOG_BUTTON_CLOSE 400
#define PAGE_DIALOG_BUTTON_ACCEPT 401
#define PAGE_DIALOG_BUTTON_CANCEL 402
#define PAGE_DIALOG_BUTTON_DEFAULT 403
#endif // __USE_MSW_PRINTING__
// Define a new text subwindow that can respond to drag-and-drop
class MyTextWindow: public wxTextWindow
{
public:
MyTextWindow(wxFrame *frame, int x=-1, int y=-1, int width=-1, int height=-1,
long style=0):
wxTextWindow(frame, x, y, width, height, style) { DragAcceptFiles(TRUE); }
public:
void OnDropFiles(int n, char *files[], int x, int y) { LoadFile(files[0]); }
void OnChar(wxKeyEvent& event);
};
// Define a new application type
class MyApp: public wxApp
{
public:
wxFrame *OnInit();
};
// Define a new frame type
class MyFrame: public wxFrame
{
public:
MyFrame(wxFrame *frame, char *title, int x, int y, int w, int h);
public:
void OnMenuCommand(int id);
void OnSize(int w, int h);
Bool OnClose();
void OnActivate(Bool active) { }
public:
MyTextWindow *textWin; // Text window for main frame
wxPanel *apanel; // Panel for adding objects
wxPanel *cpanel; // Panel for changing object
wxPanel *d